package view;

import java.awt.Color;
import java.awt.Component;

import javax.swing.*;
import javax.swing.border.LineBorder;

import model.User;

public class UserListRenderer extends JLabel implements ListCellRenderer<User> {
	private static final long serialVersionUID = 1L;

	public UserListRenderer() {
	}

	@Override
	public Component getListCellRendererComponent(JList<? extends User> arg0,
			User value, int index, boolean isSelected, boolean cellHasFocus) {
		User user = (User) value;
		setText(user.getName());

		if (isSelected) {
			setForeground(Color.WHITE);
			setBackground(Color.DARK_GRAY);
			setBorder(new LineBorder(Color.BLACK));
		} else {
			setForeground(Color.BLACK);
			setBackground(Color.WHITE);
			setBorder(null);
		}

		setOpaque(true);

		return this;
	}

}
